<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title>手机号登录/注册</title>
    <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'PingFang SC', 'Helvetica Neue', Arial, sans-serif;
        }

        body {
            background-color: #f5f7fa;
            color: #333;
            line-height: 1.6;
            max-width: 750px;
            margin: 0 auto;
            min-height: 100vh;
            padding: 20px 16px;
            position: relative;
        }

        .container {
            width: 100%;
            max-width: 480px;
            margin: 0 auto;
            padding-top: 40px;
        }

        .header {
            text-align: center;
            margin-bottom: 50px;
        }

        .logo {
            width: 80px;
            height: 80px;
            background: linear-gradient(135deg, #2196F3, #21CBF3);
            border-radius: 20px;
            display: flex;
            align-items: center;
            justify-content: center;
            margin: 0 auto 20px;
        }

        .logo i {
            font-size: 42px;
            color: white;
        }

        .header h1 {
            font-size: 28px;
            color: #333;
            font-weight: 600;
            margin-bottom: 10px;
        }

        .header p {
            font-size: 15px;
            color: #999;
        }

        .form-group {
            margin-bottom: 25px;
            background: white;
            border-radius: 12px;
            overflow: hidden;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
        }

        .input-row {
            display: flex;
            align-items: center;
            padding: 0 16px;
            border-bottom: 1px solid #eee;
        }

        .input-row:last-child {
            border-bottom: none;
        }

        .prefix {
            font-size: 16px;
            color: #333;
            margin-right: 10px;
        }

        input {
            flex: 1;
            height: 56px;
            border: none;
            outline: none;
            font-size: 17px;
            padding: 10px 0;
            background: transparent;
        }

        input::placeholder {
            color: #ccc;
        }

        .get-code {
            background-color: #2196F3;
            color: white;
            border: none;
            padding: 8px 16px;
            border-radius: 20px;
            font-size: 14px;
            cursor: pointer;
            transition: all 0.3s;
            outline: none;
            white-space: nowrap;
        }

        .get-code:disabled {
            background-color: #ccc;
            cursor: not-allowed;
        }

        .login-btn {
            display: block;
            width: 100%;
            background: #2196F3;
            color: white;
            border: none;
            border-radius: 12px;
            padding: 16px;
            font-size: 18px;
            font-weight: 500;
            margin-top: 30px;
            cursor: pointer;
            transition: all 0.3s;
            box-shadow: 0 4px 12px rgba(33, 150, 243, 0.3);
        }

        .login-btn:active {
            transform: translateY(2px);
            box-shadow: 0 2px 8px rgba(33, 150, 243, 0.3);
        }

        .terms {
            text-align: center;
            margin-top: 30px;
            font-size: 13px;
            color: #999;
        }

        .terms a {
            color: #2196F3;
            text-decoration: none;
        }

        .footer {
            position: absolute;
            bottom: 20px;
            left: 0;
            right: 0;
            text-align: center;
            font-size: 13px;
            color: #999;
        }

        .tip {
            font-size: 13px;
            color: #2196F3;
            padding: 8px 16px;
            background-color: rgba(33, 150, 243, 0.1);
            border-radius: 8px;
            margin-top: 10px;
            display: none;
        }

        .tip.show {
            display: block;
        }

        .countdown {
            color: #999;
            font-size: 14px;
        }

        @media (max-height: 600px) {
            .container {
                padding-top: 20px;
            }

            .header {
                margin-bottom: 30px;
            }
        }
    </style>
</head>

<body>
    <div class="container">
        <div class="header">
            <div class="logo">
                <i class="material-icons">smartphone</i>
            </div>
            <h1>手机号登录</h1>
            <p>未注册用户将自动创建账号</p>
        </div>

        <div class="form-group">
            <div class="input-row">
                <span class="prefix">+86</span>
                <input type="tel" id="phone" placeholder="请输入手机号" maxlength="11">
            </div>
            <div class="input-row">
                <input type="text" id="code" placeholder="请输入验证码" maxlength="6">
                <button id="getCodeBtn" class="get-code">获取验证码</button>
            </div>
        </div>

        <div id="tip" class="tip">
            提示：未注册的手机号将自动注册并登录
        </div>

        <button id="loginBtn" class="login-btn" disabled>登录 / 注册</button>

        <div class="terms">
            登录即代表同意 <a href="#">用户协议</a> 和 <a href="#">隐私政策</a>
        </div>
    </div>

    <div class="footer">
        ©2023 智能开发平台 · 安全登录
    </div>

    <script>
        document.addEventListener('DOMContentLoaded', function () {
            const phoneInput = document.getElementById('phone');
            const codeInput = document.getElementById('code');
            const getCodeBtn = document.getElementById('getCodeBtn');
            const loginBtn = document.getElementById('loginBtn');
            const tip = document.getElementById('tip');

            // 手机号输入验证
            phoneInput.addEventListener('input', function () {
                const phone = phoneInput.value;
                const isValid = /^1[3-9]\d{9}$/.test(phone);

                getCodeBtn.disabled = !isValid;
                validateForm();

                if (phone.length > 0 && !isValid) {
                    tip.textContent = '请输入正确的手机号码';
                    tip.classList.add('show');
                } else {
                    tip.classList.remove('show');
                }
            });

            // 验证码输入验证
            codeInput.addEventListener('input', validateForm);

            // 获取验证码
            getCodeBtn.addEventListener('click', function () {
                const phone = phoneInput.value;

                if (!/^1[3-9]\d{9}$/.test(phone)) {
                    tip.textContent = '请输入正确的手机号码';
                    tip.classList.add('show');
                    return;
                }

                // 显示倒计时
                let countdown = 60;
                getCodeBtn.disabled = true;
                getCodeBtn.innerHTML = `<span class="countdown">${countdown}秒</span>`;

                const timer = setInterval(function () {
                    countdown--;
                    getCodeBtn.innerHTML = `<span class="countdown">${countdown}秒</span>`;

                    if (countdown <= 0) {
                        clearInterval(timer);
                        getCodeBtn.disabled = false;
                        getCodeBtn.textContent = '重新获取';
                    }
                }, 1000);

                // 模拟发送验证码
                tip.textContent = `验证码已发送至 ${phone}，请注意查收`;
                tip.classList.add('show');

                // 实际应用中这里应该调用短信发送API
                console.log(`发送验证码到: ${phone}`);

                // 自动填写测试用验证码
                setTimeout(() => {
                    codeInput.value = '123456';
                    validateForm();
                }, 1000);
            });

            // 登录/注册按钮
            loginBtn.addEventListener('click', function () {
                const phone = phoneInput.value;
                const code = codeInput.value;

                if (!/^1[3-9]\d{9}$/.test(phone)) {
                    tip.textContent = '请输入正确的手机号码';
                    tip.classList.add('show');
                    return;
                }

                if (!/^\d{6}$/.test(code)) {
                    tip.textContent = '请输入6位验证码';
                    tip.classList.add('show');
                    return;
                }

                // 模拟登录/注册
                tip.textContent = '登录中，请稍候...';
                tip.classList.add('show');

                // 模拟API请求
                setTimeout(() => {
                    tip.textContent = `登录成功！欢迎 ${phone}`;

                    // 实际应用中这里应该跳转到首页
                    console.log(`登录成功: ${phone}`);
                }, 1500);
            });

            // 验证表单
            function validateForm() {
                const phoneValid = /^1[3-9]\d{9}$/.test(phoneInput.value);
                const codeValid = /^\d{6}$/.test(codeInput.value);

                loginBtn.disabled = !(phoneValid && codeValid);
            }

            // 初始显示提示
            setTimeout(() => {
                tip.textContent = '提示：未注册的手机号将自动注册并登录';
                tip.classList.add('show');
            }, 1000);
        });
    </script>
</body>

</html>